<?php
//make the date range
$date_array = array();
if ($type == 'last_7') {
	for ($i=7; $i>0; $i--) {
		$local_date = date('Y-m-d', mktime(0, 0, 0, date('m'), date('d')-$i));
		$date_array[$local_date] = 0;
	}
	$tickInterval = 2;
} else {
	for ($i=28; $i>0; $i--) {
		$local_date = date('Y-m-d', mktime(0, 0, 0, date('m'), date('d')-$i));
		$date_array[$local_date] = 0;
	}
	$tickInterval = 7;
}

foreach ($rows as $r) {
	$date_array[$r['local_date']] = (int)$r['visits'];
}
?>
<div style="position:relative;">
	<div id="chart-daily" style="width:100%; height:320px;"></div>
	<div style="position:absolute;bottom:0;background:#fff;height:14px;width:30%;margin-left:70%;"></div>
</div>
<script type="text/javascript">
$(function() {
	$('#chart-daily').highcharts({
		chart: {type: 'column'},
		title: {text: ''},
		xAxis: {categories: <?php echo json_encode(array_keys($date_array), true); ?>,
			tickInterval: <?php echo $tickInterval; ?>
		},
		yAxis: {min: 0, title: {text: ''}, allowDecimals: false},
		series: [{
			name: 'Visits',
			data: <?php echo json_encode(array_values($date_array), true); ?>
		}]
	});
});
</script>